package com.keyancompany.zhongbaopingtai.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.keyancompany.zhongbaopingtai.R;
import com.keyancompany.zhongbaopingtai.model.ProjectTalkComment;
import com.keyancompany.zhongbaopingtai.weight.CircleImageView;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * 悬赏详情 评论
 * <p>
 * Created by firefox on 2016/6/14.
 */
public class RewardAdapter extends ListAdapter<ProjectTalkComment> {
    public RewardAdapter(List items, Context ctx) {
        super(items, ctx);
    }

    @Override
    public int getContentViewId() {
        return R.layout.item_reward;
    }


    @Override
    public HolderView getHoldView(int position, View contentView, ViewGroup parent) {
        return new RewardHolder(contentView);
    }

    @Override
    public void setItemView(int position, HolderView contentView, ProjectTalkComment item) {

        RewardHolder hold = (RewardHolder) contentView;

        hold.author.setText(item.getUsername());
        hold.content.setText(item.getCommentmsg());
        hold.time.setText(item.getCreatetime());
        ImageLoader.getInstance().displayImage(item.getUserheadpic(), hold.head);
    }

    public class RewardHolder extends HolderView {
        private TextView author;
        private TextView content;
        private TextView time;
        private CircleImageView head;

        public RewardHolder(View view) {
            author = (TextView) view.findViewById(R.id.reward_author);
            content = (TextView) view.findViewById(R.id.reward_content);
            time = (TextView) view.findViewById(R.id.reward_time);
            head = (CircleImageView) view.findViewById(R.id.head);
        }
    }

}
